package ch.ti.bfh.app.loodel.internal.security;

import ch.ti.bfh.app.loodel.domain.member.Member;
import ch.ti.bfh.app.loodel.domain.timeslot.TimeSlot;
import ch.ti.bfh.app.loodel.domain.timeslot.TimeSlotRepository;

import javax.annotation.Resource;
import java.io.Serializable;

public class TimeSlotOwnerPermission extends AbstractOwnerPermission {

    @Resource
    private TimeSlotRepository timeSlotRepository;

    @Override
    protected Member getOwner(Serializable targetDomainObjectId) {
        final TimeSlot timeSlot = timeSlotRepository.getOne((Long) targetDomainObjectId);
        return timeSlot.getLearningEvent().getOwner();
    }
}
